--- interact_link: content/08/06/plotly8-6.ipynb kernel_name: python3 kernel_path: content/08/06 has_widgets: false title: |- Bubble Charts pagenum: 19 prev_page: url: /08/05/plotly8-5.html next_page: url: /08/07/plotly8-7.html suffix: .ipynb search: bubble id charts chart plotlybubblecharts plot ly python good want display three diminsions data third varaibles represents magnitude xy variables plotlybubblechartsbasic basic plotlybubblechartsbasiccustomizing customizing comment: "***PROGRAMMATICALLY GENERATED, DO NOT EDIT. SEE ORIGINAL FILES IN /content***" ---
Bubble Charts

Bubble Charts

Bubble charts are good to use:

  • When you want to display three diminsions of data.
  • When your third varaibles represents the magnitude of the xy variables.

Basic Bubble Chart

import plotly.graph_objects as go
import pandas as pd
from plotly.offline import init_notebook_mode, plot
from IPython.core.display import display, HTML
init_notebook_mode(connected=True)

fig = go.Figure(data=[go.Scatter(
    x=[1, 2, 3, 4], y=[10, 11, 12, 13],
    mode='markers',
    marker_size=[40, 60, 80, 100])
])

plot(fig, filename = 'figure8-6-1.html')
display(HTML('figure8-6-1.html'))

Customizing Bubble Chart

import plotly.graph_objects as go

fig = go.Figure(data=[go.Scatter(
    x=[1, 3.2, 5.4, 7.6, 9.8, 12.5],
    y=[1, 3.2, 5.4, 7.6, 9.8, 12.5],
    mode='markers',
    marker=dict(
        color=[120, 125, 130, 135, 140, 145],
        size=[15, 30, 55, 70, 90, 110], #you can also define marker size in the market dictionary
        showscale=True #This adds a color scale to the chart
        )
)])

plot(fig, filename = 'figure8-6-2.html')
display(HTML('figure8-6-2.html'))